const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                value1: '',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%")))
            },
        }
    },
    mounted() {

    },
    methods: {
        check() {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%")));
            this.postgetList(this.page)
        },
        personalAdd() {
            sessionStorage.setItem("Url", "");
            window.location.href = './sql_config.html?action=Add'
        },
        handleEdit(row) {
            let { primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
            sessionStorage.setItem("Url", row.Model_Url)
            window.location.href = "./sql_config.html?action=Modify&nodeKey=" + row[primary_key];
        },
        handleDelete(row) {
            this.$prompt("该操作将删除此条数据(" + row.SQL_SerialNumber + ")且无法恢复,请输入'确认删除'", '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                inputPattern: /^确认删除$/,
                inputErrorMessage: "请输入'确认删除'"
            }).then(() => {
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/queryMultiTableByCondition`,
                    method: "post",
                    data: {
                        Data: JSON.stringify([{
                            tableName: 'base_sql_list',
                            Condition: window.btoa(unescape(encodeURIComponent("SQL_SerialNumber='" + row.SQL_SerialNumber + "'"))),
                        }, {
                            tableName: 'base_sql_table_config',
                            Condition: window.btoa(unescape(encodeURIComponent("SQL_SerialNumber='" + row.SQL_SerialNumber + "'"))),
                        }]),
                    },
                    success: (data) => {
                        $.ajax({
                            headers: {
                                "content-type": "application/x-www-form-urlencoded",
                                "Session":'session5'
                            },
                            url: `${y}/generalDelete`,
                            method: "post",
                            data: {
                                Data: JSON.stringify(data),
                            },
                            success: (res) => {
                               if (res.Status == 'success') {
                                    this.postgetList(this.page);
                                    this.$message({
                                        type: 'success',
                                        message: '删除成功'
                                    });
                               } else {
                                    this.$message({
                                        type: 'error',
                                        message: '删除失败'
                                    });
                                }
                            },
                        });
                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest);
                    },
                });
            }).catch(() => { });
        }
    },
};



const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
